<template>
	<scroll-view 
		class="scroll-view"
		scroll-y
		refresher-enabled
		:style="'height:'+scrollViewHeight+'px'"
		:refresher-triggered="refresher"
		@refresherrefresh="startRefresher"
	>
		<view
			class="live-list"
			v-for="(item, index) in liveListDataSource" 
			:key="index"
		>
			<live-item :detail="item"/>
		</view>
	</scroll-view>
</template>


<script>
	// 组件引入
	import { liveItem } from './components/live-item/live-item.vue'; // 直播项
	import request from '@/pagesB/common/js/request/userInfo.js';

	export default {
		components: {
			liveItem
		},
		
		// 页面数据
		data() {
			return {
				scrollViewHeight: 0,
				refresher: false,
				liveListDataSource: [

				]
			}
		},
		
		onReady() {
			// 获取系统信息
			const { windowHeight } = uni.getSystemInfoSync();
			this.scrollViewHeight = windowHeight;
		},
		
		// 页面显示
		onShow() {
			this.liveEntryGetReq()
		},
		
		onLoad(options) {},
		
		// 分享到聊天
		onShareAppMessage() {},
		
		// 页面事件
		methods: {
			startRefresher() {
				this.refresher = true;
				this.liveEntryGetReq()
			},

			//获取直播入口
			liveEntryGetReq() {
				uni.showLoading({ title: "请稍后..." })
				request.liveGetList({
					data: {
						page: 1,
						pageSize: 100
					},
					success: (res) => {
						uni.hideLoading()
						this.refresher = false;
						this.liveListDataSource = res.list.list;
					},
					fail: (res) => {
						uni.hideLoading()
						this.refresher = false
					}
				});
			},
		},
		
	}
</script>

<style lang="less" scoped>
	page{
		width: 100%;
		height: 100%;
	}

  .scroll-view{
  	width: 750rpx;
  	background-color: #F2F2F2;
		
		.live-list{
			width: 750rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
		}
  }

</style>